#include <bits/stdc++.h>

using namespace std;
class Solution
{
public:
    static constexpr int mod = 1e9 + 7;
    int sumDistance(vector<int> &nums, string s, int d)
    {
        vector<long long> v;
        for (int i = 0; i < nums.size(); i++)
        {
            if (s[i] == 'R')
            {
                v.push_back(nums[i] + d);
            }
            else
            {
                v.push_back(nums[i] - d);
            }
        }

        long long ret = 0;
        sort(v.begin(), v.end());
        for (int i = 1; i < v.size(); i++)
        {
            ret += 1ll * (v[i] - v[i - 1]) * i % mod * (v.size() - i) % mod;
            ret %= mod;
        }
        return ret;
    }
};